﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Objects;

namespace MINERP.DAL.InfoConfig
{
    public  class WorkerGroupDAL:DALBase
    {
        private static ObjectQuery<tb_WorkerGroup> GetWorkerGroups()
        {
            return DataEntites.tb_WorkerGroup;
        }

        public static List<tb_WorkerGroup> GetWorkerGroupList()
        {
            List<tb_WorkerGroup> list = new List<tb_WorkerGroup>();
            foreach (var item in GetWorkerGroups())
            {
                list.Add(item);
            }
            return list;
        }


        public static tb_WorkerGroup GetWorkerGroupObj()
        {
            return DataEntites.tb_WorkerGroup.First();
        }

        public static tb_WorkerGroup GetWorkerGroupObj(int id)
        {
            return DataEntites.tb_WorkerGroup.First(g => g.GroupId == id);
        }

        public static tb_WorkerGroup GetWorkerGroupObj(string name)
        {
            return DataEntites.tb_WorkerGroup.First(g => g.GroupName == name);
        }

        public static void Add(tb_WorkerGroup obj)
        {
            DataEntites.AddTotb_WorkerGroup(obj);
            Save();
        }

        public static void Update()
        {
            Save();
        }

        public static void Delete(tb_WorkerGroup obj)
        {
            DataEntites.DeleteObject(obj);
            Save();
        }
    }
}
